﻿using System;
using System.Web.Mvc;
using System.ComponentModel.DataAnnotations;
using System.Web;
using System.Collections.Generic;

namespace RedSand.Site.Models
{
    public class ActionInfo
    {
        public int ActionID { get; set; }
        public int ParentID { get; set; }
        public string Link { get; set; }
        public string Name { get; set; }
        public string CssClass { get; set; }
        public bool ShowOnMenu { get; set; }
    }
    public class ActionList
    {
        public static System.Collections.Generic.List<ActionInfo> Items
        {
            get
            {
                var list = (List<ActionInfo>)HttpContext.Current.Cache["ActionList"];
                if (list == null)
                {
                    list = AddActionToList();
                    HttpContext.Current.Cache["ActionList"] = list;
                }
                return list;
            }
        }
        private static List<ActionInfo> AddActionToList()
        {
            List<ActionInfo> list = new List<ActionInfo>();

            //news and service
            list.Add(new ActionInfo { ActionID = 1, ParentID = 0, ShowOnMenu = true, Name = "News and Service", CssClass="rs-icon-24 icon-rss" });
            //news
            list.Add(new ActionInfo { ActionID = 11, ParentID = 1, ShowOnMenu = true, Name = "News manager", Link = "/news/manager" });
            list.Add(new ActionInfo { ActionID = 111, ParentID = 11, ShowOnMenu = false, Name = "News create", Link = "/news/create" });
            list.Add(new ActionInfo { ActionID = 112, ParentID = 11, ShowOnMenu = false, Name = "News edit", Link = "/news/edit/(.*)" });
            list.Add(new ActionInfo { ActionID = 113, ParentID = 11, ShowOnMenu = false, Name = "News delete", Link = "/news/delete/(.*)" });
            //service
            list.Add(new ActionInfo { ActionID = 12, ParentID = 1, ShowOnMenu = true, Name = "Service manager", Link = "/service/manager" });
            list.Add(new ActionInfo { ActionID = 121, ParentID = 12, ShowOnMenu = false, Name = "Service create", Link = "/service/create" });
            list.Add(new ActionInfo { ActionID = 122, ParentID = 12, ShowOnMenu = false, Name = "Service edit", Link = "/service/edit/(.*)" });
            list.Add(new ActionInfo { ActionID = 123, ParentID = 12, ShowOnMenu = false, Name = "Service delete", Link = "/service/delete/(.*)" });


            //product and maker and category and components
            list.Add(new ActionInfo { ActionID = 2, ParentID = 0, ShowOnMenu = true, Name = "Product", CssClass = "rs-icon-24 icon-laptop" });
            //category
            list.Add(new ActionInfo { ActionID = 21, ParentID = 2, ShowOnMenu = true, Name = "Category manager", Link = "/category/manager" });
            list.Add(new ActionInfo { ActionID = 211, ParentID = 21, ShowOnMenu = false, Name = "Category create", Link = "/category/create/(.*)" });
            list.Add(new ActionInfo { ActionID = 212, ParentID = 21, ShowOnMenu = false, Name = "Category edit", Link = "/category/edit/(.*)" });
            list.Add(new ActionInfo { ActionID = 213, ParentID = 21, ShowOnMenu = false, Name = "Category delete", Link = "/category/delete/(.*)" });
            //maker
            list.Add(new ActionInfo { ActionID = 22, ParentID = 2, ShowOnMenu = true, Name = "Maker manager", Link = "/maker/manager" });
            list.Add(new ActionInfo { ActionID = 221, ParentID = 22, ShowOnMenu = false, Name = "Maker create", Link = "/maker/create" });
            list.Add(new ActionInfo { ActionID = 222, ParentID = 22, ShowOnMenu = false, Name = "Maker edit", Link = "/maker/edit/(.*)" });
            list.Add(new ActionInfo { ActionID = 223, ParentID = 22, ShowOnMenu = false, Name = "Maker delete", Link = "/maker/delete/(.*)" });
            //components
            list.Add(new ActionInfo { ActionID = 23, ParentID = 2, ShowOnMenu = true, Name = "Components manager", Link = "/components/manager" });
            list.Add(new ActionInfo { ActionID = 231, ParentID = 23, ShowOnMenu = false, Name = "Components create", Link = "/components/create" });
            list.Add(new ActionInfo { ActionID = 232, ParentID = 23, ShowOnMenu = false, Name = "Components edit", Link = "/components/edit/(.*)" });
            list.Add(new ActionInfo { ActionID = 233, ParentID = 23, ShowOnMenu = false, Name = "Components delete", Link = "/components/delete/(.*)" });
            //product
            list.Add(new ActionInfo { ActionID = 24, ParentID = 2, ShowOnMenu = true, Name = "Product manager", Link = "/product/manager" });
            list.Add(new ActionInfo { ActionID = 241, ParentID = 24, ShowOnMenu = false, Name = "Product create", Link = "/product/create/(.*)" });
            list.Add(new ActionInfo { ActionID = 242, ParentID = 24, ShowOnMenu = false, Name = "Product edit", Link = "/product/edit/(.*)" });
            list.Add(new ActionInfo { ActionID = 243, ParentID = 24, ShowOnMenu = false, Name = "Product delete", Link = "/product/delete/(.*)" });
            
            return list;
        }
    }
}
